<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
		+ request.getServerName() + ":" + request.getServerPort()
		+ path + "/";

String url = (String)request.getAttribute("url");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<base href="<%=basePath%>"/>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<SCRIPT language="JavaScript" src="<%=basePath%>resources/jquery/jquery-1.6.4.min.js"></SCRIPT>
		<link href="<%=basePath%>styles/login8reg.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath%>dwr/engine.js"></script>
		<script type="text/javascript" src="<%=basePath%>dwr/interface/ajaxService.js"></script>
		
		<SCRIPT language="JavaScript">
		var basePath = '<%= basePath %>';
		
		function doajaxlogin(){
		    var userLoginId = document.getElementById('yh').value;
		    var userPawd = document.getElementById('mm').value;
		     
		    if (userLoginId == "") {
		        //document.getElementById('loginajax').innerHTML = "请输入用户登录账号";
		        $('#loginajax').html("请输入用户登录账号");
		        document.getElementById('yh').focus();
		        return false;
		    }
		    if (isContainChinese(userLoginId)) {
		    	//document.getElementById('loginajax').innerHTML = "用户登录账号不接受中文";
		    	$('#loginajax').html("用户登录账号不接受中文");
		        document.getElementById('yh').focus();
		        return false;
		    }
		   
		    if (userPawd == "") {
		    	//document.getElementById('loginajax').innerHTML = "请输入登录密码";
		    	$('#loginajax').html("请输入登录密码");
		        document.getElementById('mm').focus();
		        return false;
		    }
		    
		    $.post(basePath+'identity/ajaxlogin.action?act=login', {'yonghu': userLoginId, 'mima': userPawd}, function(data) {
				var jsonarray = eval("("+data+")");
				var obj = jsonarray;
		    	if(obj.msg=='ok'){//成功登录
		    		addTab(null, <%=url%>, '1', '0')
			    }else{
			    	$('#loginajax').html(obj.msg);
				}
			});
		}
	
		/** 转码检验字符串中是否包含中文 */
		function isContainChinese(str){
			if(!str){ //如果 str 为空则直接返回 false
			    return false;
			}
			if(escape(str).indexOf("%u") != -1){
			    // 包含有中文
			    return true;
			}else{
			    // 没有中文
			    return false;
			}
		}
		
		$(document).ready(function() {
			if (document.getElementById("yh"))
				document.getElementById("yh").focus();
	
		});
		
	</SCRIPT>
<style>
body{
font-size: 15px;
}
input.smalbutton {
	background: url("../images/pages/qtyebigbutton.png") repeat-x ;
	width: 110px;
	height: 32px;
	cursor: pointer;
	font-family: fantasy;
	border: #C30066 1px solid;
	color:#FEF3F5;
	background-color: #F35A76;
	font-size: 15px;
	font-weight: bold;
}
</style>
	</head>

	<body>

		<form id="userloginForm" name="userloginForm" theme="simple" action="login" namespace="/identity" method="post">
			<div style="margin-left: 210px;margin-top: 10px;font-size: 12px;color: red;" id="loginajax">&nbsp;</div>
    		<div style="margin-left: 50px;">
    					<table border="0" cellspacing="0" cellpadding="0" class="form-table">
    								<tr style="height: 40px;">
    									<td width="154" valign="middle" align="right">账　号：</td>
    									<td width="280">
    										<input type="text" size="20" id="yh" style="width: 200px;"/>
									</td>

    								</tr>
    								<tr style="height: 40px;">
    									<td valign="middle" align="right">密　码：</td>
    									<td>
    										<input type="password" size="20" id="mm" style="width: 200px;"/>
									</td>
    								</tr>
    								<tr style="height:40px;">
    									<td>&nbsp;</td>

    									<td>
    										<span id="postButtonDiv"><input id="postButton" tabindex="4" onkeydown="return ys_onkeydown(2,event)"  class="smalbutton" onclick="doajaxlogin()" value="登 录" type="button"/></span>
    										<span id="postButtonWait" style="display:none"><img src="resources/images/loading.gif" /> 处理中，请稍候......&nbsp;&nbsp;&nbsp;</span>
    									</td>
    								</tr>
    								
    					</table>
     		</div>
		</form>
   
	</body>
</html>
